import junit.framework.TestCase;

import java.util.ArrayList;
import de.unibi.comet.ac.AhoCorasickAutomaton;
import de.unibi.comet.ac.AhoCorasickNode;
import de.unibi.comet.ac.StringSetProvider;
import de.unibi.comet.util.PreOrderIterator;

public class AhoCorasickAutomatonTest extends TestCase {

	/** Test if nodes are numbered in pre-order fashion. */
	public void testPreOrderProperty() {
		ArrayList<String> l = new ArrayList<String>();
		l.add("bert");
		l.add("kunibert");
		l.add("till");
		l.add("nina");
		StringSetProvider ssp = new StringSetProvider(l);
		AhoCorasickAutomaton aca = new AhoCorasickAutomaton();
		aca.build(ssp);
		PreOrderIterator<AhoCorasickNode> it = new PreOrderIterator<AhoCorasickNode>(aca.getRoot());
		int i = 0;
		while (it.hasNext()) {
			assertEquals(i, it.next().getNr());
			i+=1;
		}
	}
	
}
